{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723\n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520\n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674\n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556\n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# import pandas \n",
    "import pandas as pd\n",
    "\n",
    "# Read the data using csv\n",
    "data=pd.read_csv('employee.csv')\n",
    "\n",
    "# See initial 5 records\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>NaN</td>\n",
       "      <td>62000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>James Authur</td>\n",
       "      <td>54.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>54.0</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G3</td>\n",
       "      <td>901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.0</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score\n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711\n",
       "5  Satyam Sharma   NaN  62000.0    NaN       Sales    G3                649\n",
       "6   James Authur  54.0      NaN      F  Operations    G3                 53\n",
       "7     Josh Wills  54.0  52000.0      F     Finance    G3                901\n",
       "8       Leo Duck  23.0  98000.0      M       Sales    G4                709"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# See last 5 records\n",
    "data.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['name', 'age', 'income', 'gender', 'department', 'grade',\n",
      "       'performance_score'],\n",
      "      dtype='object')\n"
     ]
    }
   ],
   "source": [
    "# Print list of columns in the data\n",
    "print(data.columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(9, 7)\n"
     ]
    }
   ],
   "source": [
    "# Print the shape of a DataFrame\n",
    "print(data.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 9 entries, 0 to 8\n",
      "Data columns (total 7 columns):\n",
      " #   Column             Non-Null Count  Dtype  \n",
      "---  ------             --------------  -----  \n",
      " 0   name               9 non-null      object \n",
      " 1   age                7 non-null      float64\n",
      " 2   income             7 non-null      float64\n",
      " 3   gender             7 non-null      object \n",
      " 4   department         9 non-null      object \n",
      " 5   grade              9 non-null      object \n",
      " 6   performance_score  9 non-null      int64  \n",
      "dtypes: float64(2), int64(1), object(4)\n",
      "memory usage: 632.0+ bytes\n"
     ]
    }
   ],
   "source": [
    "# Check the information of DataFrame\n",
    "data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>7.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>9.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>40.428571</td>\n",
       "      <td>52857.142857</td>\n",
       "      <td>610.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>12.204605</td>\n",
       "      <td>26028.372797</td>\n",
       "      <td>235.671912</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>23.000000</td>\n",
       "      <td>16000.000000</td>\n",
       "      <td>53.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>31.000000</td>\n",
       "      <td>38500.000000</td>\n",
       "      <td>556.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>45.000000</td>\n",
       "      <td>52000.000000</td>\n",
       "      <td>674.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>49.500000</td>\n",
       "      <td>63500.000000</td>\n",
       "      <td>711.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>54.000000</td>\n",
       "      <td>98000.000000</td>\n",
       "      <td>901.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             age        income  performance_score\n",
       "count   7.000000      7.000000           9.000000\n",
       "mean   40.428571  52857.142857         610.666667\n",
       "std    12.204605  26028.372797         235.671912\n",
       "min    23.000000  16000.000000          53.000000\n",
       "25%    31.000000  38500.000000         556.000000\n",
       "50%    45.000000  52000.000000         674.000000\n",
       "75%    49.500000  63500.000000         711.000000\n",
       "max    54.000000  98000.000000         901.000000"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check the descriptive statistics\n",
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>department</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>Operations</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>Finance</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>Finance</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>Sales</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>Operations</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>Sales</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>James Authur</td>\n",
       "      <td>Operations</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>Finance</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>Sales</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name  department\n",
       "0    Allen Smith  Operations\n",
       "1        S Kumar     Finance\n",
       "2    Jack Morgan     Finance\n",
       "3      Ying Chin       Sales\n",
       "4  Dheeraj Patel  Operations\n",
       "5  Satyam Sharma       Sales\n",
       "6   James Authur  Operations\n",
       "7     Josh Wills     Finance\n",
       "8       Leo Duck       Sales"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter columns \n",
    "data.filter(['name', 'department'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      Allen Smith\n",
       "1          S Kumar\n",
       "2      Jack Morgan\n",
       "3        Ying Chin\n",
       "4    Dheeraj Patel\n",
       "5    Satyam Sharma\n",
       "6     James Authur\n",
       "7       Josh Wills\n",
       "8         Leo Duck\n",
       "Name: name, dtype: object"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter column “name”\n",
    "data['name']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>James Authur</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name\n",
       "0    Allen Smith\n",
       "1        S Kumar\n",
       "2    Jack Morgan\n",
       "3      Ying Chin\n",
       "4  Dheeraj Patel\n",
       "5  Satyam Sharma\n",
       "6   James Authur\n",
       "7     Josh Wills\n",
       "8       Leo Duck"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter column “name” \n",
    "data[['name']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>department</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>Operations</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>Finance</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>Finance</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>Sales</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>Operations</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>Sales</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>James Authur</td>\n",
       "      <td>Operations</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>Finance</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>Sales</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name  department\n",
       "0    Allen Smith  Operations\n",
       "1        S Kumar     Finance\n",
       "2    Jack Morgan     Finance\n",
       "3      Ying Chin       Sales\n",
       "4  Dheeraj Patel  Operations\n",
       "5  Satyam Sharma       Sales\n",
       "6   James Authur  Operations\n",
       "7     Josh Wills     Finance\n",
       "8       Leo Duck       Sales"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter two columns: name and department\n",
    "data[['name','department']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          name   age   income gender  department grade  performance_score\n",
       "0  Allen Smith  45.0      NaN    NaN  Operations    G3                723\n",
       "1      S Kumar   NaN  16000.0      F     Finance    G0                520\n",
       "2  Jack Morgan  32.0  35000.0      M     Finance    G2                674"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Select rows for specific index\n",
    "data.filter([0,1,2],axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score\n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674\n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556\n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter data using slicing\n",
    "data[2:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>NaN</td>\n",
       "      <td>62000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.0</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender department grade  performance_score\n",
       "3      Ying Chin  45.0  65000.0      F      Sales    G3                556\n",
       "5  Satyam Sharma   NaN  62000.0    NaN      Sales    G3                649\n",
       "8       Leo Duck  23.0  98000.0      M      Sales    G4                709"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter data for specific value \n",
    "data[data.department=='Sales']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>NaN</td>\n",
       "      <td>62000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>54.0</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G3</td>\n",
       "      <td>901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.0</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender department grade  performance_score\n",
       "1        S Kumar   NaN  16000.0      F    Finance    G0                520\n",
       "2    Jack Morgan  32.0  35000.0      M    Finance    G2                674\n",
       "3      Ying Chin  45.0  65000.0      F      Sales    G3                556\n",
       "5  Satyam Sharma   NaN  62000.0    NaN      Sales    G3                649\n",
       "7     Josh Wills  54.0  52000.0      F    Finance    G3                901\n",
       "8       Leo Duck  23.0  98000.0      M      Sales    G4                709"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Select data for multiple values\n",
    "data[data.department.isin(['Sales','Finance'])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>54.0</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G3</td>\n",
       "      <td>901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.0</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723\n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711\n",
       "7     Josh Wills  54.0  52000.0      F     Finance    G3                901\n",
       "8       Leo Duck  23.0  98000.0      M       Sales    G4                709"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter employee who has more than 700 performance score\n",
    "data[(data.performance_score >=700)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>NaN</td>\n",
       "      <td>62000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>649</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender department grade  performance_score\n",
       "1        S Kumar   NaN  16000.0      F    Finance    G0                520\n",
       "2    Jack Morgan  32.0  35000.0      M    Finance    G2                674\n",
       "3      Ying Chin  45.0  65000.0      F      Sales    G3                556\n",
       "5  Satyam Sharma   NaN  62000.0    NaN      Sales    G3                649"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter employee who has more than 500 and less than 700 performance score\n",
    "data[(data.performance_score >=500) & (data.performance_score < 700)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>James Authur</td>\n",
       "      <td>54.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           name   age  income gender  department grade  performance_score\n",
       "6  James Authur  54.0     NaN      F  Operations    G3                 53"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Filter employee who has performance score less than 500\n",
    "data.query('performance_score<500')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>54.0</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G3</td>\n",
       "      <td>901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.0</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score\n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674\n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556\n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711\n",
       "7     Josh Wills  54.0  52000.0      F     Finance    G3                901\n",
       "8       Leo Duck  23.0  98000.0      M       Sales    G4                709"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Drop missing value rows using dropna() function\n",
    "# Read the data\n",
    "data=pd.read_csv('employee.csv')\n",
    "data=data.dropna()\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>40.428571</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.000000</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.000000</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.000000</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>40.428571</td>\n",
       "      <td>62000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>James Authur</td>\n",
       "      <td>54.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>54.000000</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G3</td>\n",
       "      <td>901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.000000</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name        age   income gender  department grade  \\\n",
       "0    Allen Smith  45.000000      NaN    NaN  Operations    G3   \n",
       "1        S Kumar  40.428571  16000.0      F     Finance    G0   \n",
       "2    Jack Morgan  32.000000  35000.0      M     Finance    G2   \n",
       "3      Ying Chin  45.000000  65000.0      F       Sales    G3   \n",
       "4  Dheeraj Patel  30.000000  42000.0      F  Operations    G2   \n",
       "5  Satyam Sharma  40.428571  62000.0    NaN       Sales    G3   \n",
       "6   James Authur  54.000000      NaN      F  Operations    G3   \n",
       "7     Josh Wills  54.000000  52000.0      F     Finance    G3   \n",
       "8       Leo Duck  23.000000  98000.0      M       Sales    G4   \n",
       "\n",
       "   performance_score  \n",
       "0                723  \n",
       "1                520  \n",
       "2                674  \n",
       "3                556  \n",
       "4                711  \n",
       "5                649  \n",
       "6                 53  \n",
       "7                901  \n",
       "8                709  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Read the data\n",
    "data=pd.read_csv('employee.csv')\n",
    "\n",
    "# Fill all the missing values in the age column with mean of the age column\n",
    "data['age']=data.age.fillna(data.age.mean())\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.000000</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>40.428571</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.000000</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.000000</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.000000</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>40.428571</td>\n",
       "      <td>62000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>James Authur</td>\n",
       "      <td>54.000000</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>54.000000</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G3</td>\n",
       "      <td>901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.000000</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name        age   income gender  department grade  \\\n",
       "0    Allen Smith  45.000000  52000.0    NaN  Operations    G3   \n",
       "1        S Kumar  40.428571  16000.0      F     Finance    G0   \n",
       "2    Jack Morgan  32.000000  35000.0      M     Finance    G2   \n",
       "3      Ying Chin  45.000000  65000.0      F       Sales    G3   \n",
       "4  Dheeraj Patel  30.000000  42000.0      F  Operations    G2   \n",
       "5  Satyam Sharma  40.428571  62000.0    NaN       Sales    G3   \n",
       "6   James Authur  54.000000  52000.0      F  Operations    G3   \n",
       "7     Josh Wills  54.000000  52000.0      F     Finance    G3   \n",
       "8       Leo Duck  23.000000  98000.0      M       Sales    G4   \n",
       "\n",
       "   performance_score  \n",
       "0                723  \n",
       "1                520  \n",
       "2                674  \n",
       "3                556  \n",
       "4                711  \n",
       "5                649  \n",
       "6                 53  \n",
       "7                901  \n",
       "8                709  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Fill all the missing values in the income column with a median of the income column\n",
    "data['income']=data.income.fillna(data.income.median())\n",
    "data\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.000000</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>40.428571</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.000000</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.000000</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.000000</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>40.428571</td>\n",
       "      <td>62000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>James Authur</td>\n",
       "      <td>54.000000</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>54.000000</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G3</td>\n",
       "      <td>901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.000000</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name        age   income gender  department grade  \\\n",
       "0    Allen Smith  45.000000  52000.0      F  Operations    G3   \n",
       "1        S Kumar  40.428571  16000.0      F     Finance    G0   \n",
       "2    Jack Morgan  32.000000  35000.0      M     Finance    G2   \n",
       "3      Ying Chin  45.000000  65000.0      F       Sales    G3   \n",
       "4  Dheeraj Patel  30.000000  42000.0      F  Operations    G2   \n",
       "5  Satyam Sharma  40.428571  62000.0      F       Sales    G3   \n",
       "6   James Authur  54.000000  52000.0      F  Operations    G3   \n",
       "7     Josh Wills  54.000000  52000.0      F     Finance    G3   \n",
       "8       Leo Duck  23.000000  98000.0      M       Sales    G4   \n",
       "\n",
       "   performance_score  \n",
       "0                723  \n",
       "1                520  \n",
       "2                674  \n",
       "3                556  \n",
       "4                711  \n",
       "5                649  \n",
       "6                 53  \n",
       "7                901  \n",
       "8                709  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Fill all the missing values in the gender column(category column) with the mode of the gender column\n",
    "data['gender']=data['gender'].fillna(data['gender'].mode()[0])\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>NaN</td>\n",
       "      <td>62000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>James Authur</td>\n",
       "      <td>54.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Josh Wills</td>\n",
       "      <td>54.0</td>\n",
       "      <td>52000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G3</td>\n",
       "      <td>901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.0</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723\n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520\n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674\n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556\n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711\n",
       "5  Satyam Sharma   NaN  62000.0    NaN       Sales    G3                649\n",
       "6   James Authur  54.0      NaN      F  Operations    G3                 53\n",
       "7     Josh Wills  54.0  52000.0      F     Finance    G3                901\n",
       "8       Leo Duck  23.0  98000.0      M       Sales    G4                709"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Read the data\n",
    "data=pd.read_csv('employee.csv')\n",
    "\n",
    "# Dropping the outliers using Standard Deviation\n",
    "upper_limit= data['performance_score'].mean () + 3 * data['performance_score'].std ()\n",
    "lower_limit = data['performance_score'].mean () - 3 * data['performance_score'].std () \n",
    "data = data[(data['performance_score'] < upper_limit) & (data['performance_score'] > lower_limit)]\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Satyam Sharma</td>\n",
       "      <td>NaN</td>\n",
       "      <td>62000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Leo Duck</td>\n",
       "      <td>23.0</td>\n",
       "      <td>98000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G4</td>\n",
       "      <td>709</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723\n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520\n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674\n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556\n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711\n",
       "5  Satyam Sharma   NaN  62000.0    NaN       Sales    G3                649\n",
       "8       Leo Duck  23.0  98000.0      M       Sales    G4                709"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Read the data\n",
    "data=pd.read_csv('employee.csv')\n",
    "\n",
    "# Drop the outlier observations using Percentiles\n",
    "upper_limit = data['performance_score'].quantile(.99)\n",
    "lower_limit = data['performance_score'].quantile(.01)\n",
    "data = data[(data['performance_score'] < upper_limit) & (data['performance_score'] > lower_limit)]\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "      <th>F</th>\n",
       "      <th>M</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score  \\\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723   \n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520   \n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674   \n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556   \n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711   \n",
       "\n",
       "   F  M  \n",
       "0  0  0  \n",
       "1  1  0  \n",
       "2  0  1  \n",
       "3  1  0  \n",
       "4  1  0  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Read the data\n",
    "data=pd.read_csv('employee.csv')\n",
    "# Dummy encoding\n",
    "encoded_data = pd.get_dummies(data['gender'])\n",
    "\n",
    "# Join the encoded _data with original dataframe\n",
    "data = data.join(encoded_data)\n",
    "\n",
    "# Check the top-5 records of the dataframe\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0.],\n",
       "       [1., 0.],\n",
       "       [0., 1.],\n",
       "       [1., 0.],\n",
       "       [1., 0.],\n",
       "       [1., 0.],\n",
       "       [1., 0.],\n",
       "       [1., 0.],\n",
       "       [0., 1.]])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Import one hot encoder  \n",
    "from sklearn.preprocessing import OneHotEncoder \n",
    "  \n",
    "# Initialize the one hot encoder object\n",
    "onehotencoder = OneHotEncoder() \n",
    "\n",
    "# Fill all the missing values in income column(category column) with mode of age column\n",
    "data['gender']=data['gender'].fillna(data['gender'].mode()[0])\n",
    "\n",
    "# Fit and transforms the gender column\n",
    "onehotencoder.fit_transform(data[['gender']]).toarray()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 0 0 2 1 2 1 0 2]\n"
     ]
    }
   ],
   "source": [
    "# Import pandas  \n",
    "import pandas as pd\n",
    "# Read the data\n",
    "data=pd.read_csv('employee.csv')\n",
    "# Import LabelEncoder\n",
    "from sklearn.preprocessing import LabelEncoder\n",
    "# Instantiate the Label Encoder Object\n",
    "label_encoder = LabelEncoder()\n",
    "# Fit and transform the column\n",
    "encoded_data = label_encoder.fit_transform(data['department'])\n",
    "# Print the encoded\n",
    "print(encoded_data) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Finance' 'Finance' 'Operations' 'Sales']\n"
     ]
    }
   ],
   "source": [
    "# Perform inverse encoding\n",
    "inverse_encode=label_encoder.inverse_transform([0, 0, 1, 2])\n",
    "# Print inverse encode\n",
    "print(inverse_encode) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "      <th>grade_encoded</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score  \\\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723   \n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520   \n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674   \n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556   \n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711   \n",
       "\n",
       "   grade_encoded  \n",
       "0              2  \n",
       "1              0  \n",
       "2              1  \n",
       "3              2  \n",
       "4              1  "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Import pandas and OrdinalEncoder\n",
    "import pandas as pd\n",
    "from sklearn.preprocessing import OrdinalEncoder\n",
    "\n",
    "# Load the data\n",
    "data=pd.read_csv('employee.csv')\n",
    "\n",
    "# Initialize OrdinalEncoder with order \n",
    "order_encoder=OrdinalEncoder(categories=['G0','G1','G2','G3','G4'])\n",
    "\n",
    "# fit and transform the grade \n",
    "data['grade_encoded'] = label_encoder.fit_transform(data['grade'])\n",
    "\n",
    "# Check top-5 records of the dataframe\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "      <th>grade_encoded</th>\n",
       "      <th>performance_std_scaler</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "      <td>2</td>\n",
       "      <td>0.505565</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.408053</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "      <td>1</td>\n",
       "      <td>0.285037</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "      <td>2</td>\n",
       "      <td>-0.246032</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "      <td>1</td>\n",
       "      <td>0.451558</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score  \\\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723   \n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520   \n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674   \n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556   \n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711   \n",
       "\n",
       "   grade_encoded  performance_std_scaler  \n",
       "0              2                0.505565  \n",
       "1              0               -0.408053  \n",
       "2              1                0.285037  \n",
       "3              2               -0.246032  \n",
       "4              1                0.451558  "
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Import StandardScaler(or z-score normalization) \n",
    "from sklearn.preprocessing import StandardScaler \n",
    "  \n",
    "# Initialize the StandardScaler \n",
    "scaler = StandardScaler() \n",
    "  \n",
    "# To scale data \n",
    "scaler.fit(data['performance_score'].values.reshape(-1,1)) \n",
    "data['performance_std_scaler']=scaler.transform(data['performance_score'].values.reshape(-1,1))\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "      <th>grade_encoded</th>\n",
       "      <th>performance_std_scaler</th>\n",
       "      <th>performance_minmax_scaler</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "      <td>2</td>\n",
       "      <td>0.505565</td>\n",
       "      <td>0.790094</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.408053</td>\n",
       "      <td>0.550708</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "      <td>1</td>\n",
       "      <td>0.285037</td>\n",
       "      <td>0.732311</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "      <td>2</td>\n",
       "      <td>-0.246032</td>\n",
       "      <td>0.593160</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "      <td>1</td>\n",
       "      <td>0.451558</td>\n",
       "      <td>0.775943</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score  \\\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723   \n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520   \n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674   \n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556   \n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711   \n",
       "\n",
       "   grade_encoded  performance_std_scaler  performance_minmax_scaler  \n",
       "0              2                0.505565                   0.790094  \n",
       "1              0               -0.408053                   0.550708  \n",
       "2              1                0.285037                   0.732311  \n",
       "3              2               -0.246032                   0.593160  \n",
       "4              1                0.451558                   0.775943  "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Import MinMaxScaler\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "\n",
    "# Initialise the MinMaxScaler \n",
    "scaler = MinMaxScaler()\n",
    "\n",
    "# To scale data \n",
    "scaler.fit(data['performance_score'].values.reshape(-1,1)) \n",
    "data['performance_minmax_scaler']=scaler.transform(data['performance_score'].values.reshape(-1,1))\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "      <th>grade_encoded</th>\n",
       "      <th>performance_std_scaler</th>\n",
       "      <th>performance_minmax_scaler</th>\n",
       "      <th>performance_robust_scaler</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "      <td>2</td>\n",
       "      <td>0.505565</td>\n",
       "      <td>0.790094</td>\n",
       "      <td>0.316129</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.408053</td>\n",
       "      <td>0.550708</td>\n",
       "      <td>-0.993548</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "      <td>1</td>\n",
       "      <td>0.285037</td>\n",
       "      <td>0.732311</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "      <td>2</td>\n",
       "      <td>-0.246032</td>\n",
       "      <td>0.593160</td>\n",
       "      <td>-0.761290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "      <td>1</td>\n",
       "      <td>0.451558</td>\n",
       "      <td>0.775943</td>\n",
       "      <td>0.238710</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score  \\\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723   \n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520   \n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674   \n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556   \n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711   \n",
       "\n",
       "   grade_encoded  performance_std_scaler  performance_minmax_scaler  \\\n",
       "0              2                0.505565                   0.790094   \n",
       "1              0               -0.408053                   0.550708   \n",
       "2              1                0.285037                   0.732311   \n",
       "3              2               -0.246032                   0.593160   \n",
       "4              1                0.451558                   0.775943   \n",
       "\n",
       "   performance_robust_scaler  \n",
       "0                   0.316129  \n",
       "1                  -0.993548  \n",
       "2                   0.000000  \n",
       "3                  -0.761290  \n",
       "4                   0.238710  "
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Import RobustScaler\n",
    "from sklearn.preprocessing import RobustScaler\n",
    "\n",
    "# Initialise the RobustScaler \n",
    "scaler = RobustScaler()\n",
    "\n",
    "# To scale data \n",
    "scaler.fit(data['performance_score'].values.reshape(-1,1)) \n",
    "data['performance_robust_scaler']=scaler.transform(data['performance_score'].values.reshape(-1,1))\n",
    "# See initial 5 records\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "      <th>performance_grade</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "      <td>A</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "      <td>B</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "      <td>B</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "      <td>B</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "      <td>A</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score  \\\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723   \n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520   \n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674   \n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556   \n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711   \n",
       "\n",
       "  performance_grade  \n",
       "0                 A  \n",
       "1                 B  \n",
       "2                 B  \n",
       "3                 B  \n",
       "4                 A  "
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Read the data\n",
    "data=pd.read_csv('employee.csv')\n",
    "# Create performance grade function \n",
    "def performance_grade(score):\n",
    "    if score>=700:\n",
    "        return 'A'\n",
    "    elif score<700 and score >= 500:\n",
    "        return 'B'\n",
    "    else:\n",
    "        return 'C'\n",
    "# Apply performance grade function on whole DataFrame using apply() function.    \n",
    "data['performance_grade']=data.performance_score.apply(performance_grade)    \n",
    "# See initial 5 records\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>income</th>\n",
       "      <th>gender</th>\n",
       "      <th>department</th>\n",
       "      <th>grade</th>\n",
       "      <th>performance_score</th>\n",
       "      <th>performance_grade</th>\n",
       "      <th>first_name</th>\n",
       "      <th>last_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Allen Smith</td>\n",
       "      <td>45.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G3</td>\n",
       "      <td>723</td>\n",
       "      <td>A</td>\n",
       "      <td>Allen</td>\n",
       "      <td>Smith</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S Kumar</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G0</td>\n",
       "      <td>520</td>\n",
       "      <td>B</td>\n",
       "      <td>S</td>\n",
       "      <td>Kumar</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jack Morgan</td>\n",
       "      <td>32.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>M</td>\n",
       "      <td>Finance</td>\n",
       "      <td>G2</td>\n",
       "      <td>674</td>\n",
       "      <td>B</td>\n",
       "      <td>Jack</td>\n",
       "      <td>Morgan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ying Chin</td>\n",
       "      <td>45.0</td>\n",
       "      <td>65000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Sales</td>\n",
       "      <td>G3</td>\n",
       "      <td>556</td>\n",
       "      <td>B</td>\n",
       "      <td>Ying</td>\n",
       "      <td>Chin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dheeraj Patel</td>\n",
       "      <td>30.0</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>F</td>\n",
       "      <td>Operations</td>\n",
       "      <td>G2</td>\n",
       "      <td>711</td>\n",
       "      <td>A</td>\n",
       "      <td>Dheeraj</td>\n",
       "      <td>Patel</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            name   age   income gender  department grade  performance_score  \\\n",
       "0    Allen Smith  45.0      NaN    NaN  Operations    G3                723   \n",
       "1        S Kumar   NaN  16000.0      F     Finance    G0                520   \n",
       "2    Jack Morgan  32.0  35000.0      M     Finance    G2                674   \n",
       "3      Ying Chin  45.0  65000.0      F       Sales    G3                556   \n",
       "4  Dheeraj Patel  30.0  42000.0      F  Operations    G2                711   \n",
       "\n",
       "  performance_grade first_name last_name  \n",
       "0                 A      Allen     Smith  \n",
       "1                 B          S     Kumar  \n",
       "2                 B       Jack    Morgan  \n",
       "3                 B       Ying      Chin  \n",
       "4                 A    Dheeraj     Patel  "
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Split the name column in first and last name\n",
    "data['first_name']=data.name.str.split(\" \").map(lambda var: var[0])\n",
    "data['last_name']=data.name.str.split(\" \").map(lambda var: var[1])\n",
    "# Check top-5 records \n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
